package bean;

import comm.DataManagement;
import comm.User;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.scene.control.CheckBox;

public class UserRow extends User{
	private static int count=1;
	private final SimpleStringProperty threadStatus=new SimpleStringProperty("no Login");
	private final SimpleStringProperty packetStatus=new SimpleStringProperty("no Login");
	private final SimpleStringProperty nickName=new SimpleStringProperty("no Login");
	private final SimpleDoubleProperty progress=new SimpleDoubleProperty(0);
	//private final SimpleBooleanProperty choice=new SimpleBooleanProperty(false);
	private final CheckBox choice=new CheckBox();
	private int sequence;
	
	{
		setSequence(count++);
	}
	
	public UserRow(User user){
		super(user);
		choice.selectedProperty().addListener(e->{
			boolean selected=choice.isSelected();
			if (selected) {
				DataManagement.addSelected(user);
			}else {
				DataManagement.removeSelected(user);
			}
		});;
	}
	

	public int getSequence() {
		return sequence;
	}

	public void setSequence(int sequence) {
		this.sequence = sequence;
	}

	public String getThreadStatus() {
		return threadStatus.get();
	}
	
	public SimpleStringProperty threadStatusProperty() {
		return threadStatus;
	}

	public String getPacketStatus() {
		return packetStatus.get();
	}
	
	public SimpleStringProperty packetStatusProperty() {
		return packetStatus;
	}

	public SimpleIntegerProperty oldScoreProperty() {
		return oldScore;
	}
	public String getQq() {
		return qq.get();
	}


	public String getNickName() {
		return nickName.get();
	}

	public double getProgress() {
		return progress.get();
	}
	public SimpleDoubleProperty progressProperty() {
		return progress;
	}
	public void setProgress(double progress) {
		this.progress.set(progress);
	}
	
	public void setThreadStatus(String threadStatus) {
		this.threadStatus.set(threadStatus);
	}
	
	public void setPacketStatus(String packetStatus) {
		this.packetStatus.set(packetStatus);
	}

	public SimpleIntegerProperty nowScoreProperty() {
		return nowScore;
	}
	
	public SimpleIntegerProperty profitProperty() {
		return profit;
	}
	/**
	 * @return the choice
	 */
	public CheckBox getChoice() {
		return choice;
	}
	
	public void allStatucSet(String status) {
		threadStatus.set(status);
		packetStatus.set(status);
	}
	
}
